<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="工单号" prop="orderNum">
        <el-input
          v-model="queryParams.orderNum"
          placeholder="请输入工单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="产品id" prop="productId">
        <el-input
          v-model="queryParams.productId"
          placeholder="请输入产品id"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="产品名" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="产品规格型号" prop="productModel">
        <el-input
          v-model="queryParams.productModel"
          placeholder="请输入产品规格型号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品单位" prop="productUnit">
        <el-input
          v-model="queryParams.productUnit"
          placeholder="请输入产品单位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入库状态(0=未入库，1=已入库)" prop="inStatus">
        <el-select v-model="queryParams.inStatus" placeholder="请选择入库状态(0=未入库，1=已入库)" clearable size="small">
          <el-option
            v-for="dict in inStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="打包单号" prop="packingNum">
        <el-input
          v-model="queryParams.packingNum"
          placeholder="请输入打包单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="数量" prop="quantity">
        <el-input
          v-model="queryParams.quantity"
          placeholder="请输入数量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="打包人" prop="packer">
        <el-input
          v-model="queryParams.packer"
          placeholder="请输入打包人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="打包时间" prop="packingTime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.packingTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择打包时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="报工单号" prop="reportNum">
        <el-input
          v-model="queryParams.reportNum"
          placeholder="请输入报工单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建人" prop="createUser">
        <el-input
          v-model="queryParams.createUser"
          placeholder="请输入创建人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="修改人" prop="updateUser">
        <el-input
          v-model="queryParams.updateUser"
          placeholder="请输入修改人"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否删除  0否  1是" prop="isDel">
        <el-input
          v-model="queryParams.isDel"
          placeholder="请输入是否删除  0否  1是"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态类型(0=良品 1=不良品 2=待检品)" prop="stateType">
        <el-select v-model="queryParams.stateType" placeholder="请选择状态类型(0=良品 1=不良品 2=待检品)" clearable size="small">
          <el-option
            v-for="dict in stateTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="打包状态" prop="packingStatus">
        <el-select v-model="queryParams.packingStatus" placeholder="请选择打包状态" clearable size="small">
          <el-option
            v-for="dict in packingStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="auditStatus">
        <el-select v-model="queryParams.auditStatus" placeholder="请选择审核状态" clearable size="small">
          <el-option
            v-for="dict in auditStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="来源" prop="source">
        <el-input
          v-model="queryParams.source"
          placeholder="请输入来源"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="仓库" prop="lssuingWarehouse">
        <el-input
          v-model="queryParams.lssuingWarehouse"
          placeholder="请输入仓库"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['prodmanage:packing:add']"
        >新增</el-button> 
      </el-col>
            <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdatee"
          v-hasPermi="['prodmanage:packing:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['prodmanage:packing:edit']"
          >入库</el-button
        >
      </el-col>
       <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['prodmanage:packing:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['prodmanage:packing:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="packingList"
      @selection-change="handleSelectionChange"
      border
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="打包id" align="center" prop="packingId"  :show-overflow-tooltip="true"/>
      <el-table-column label="工单号" align="center" prop="orderNum"  :show-overflow-tooltip="true"/>
      <el-table-column label="产品id" align="center" prop="productId"  :show-overflow-tooltip="true"/>
      <el-table-column label="产品代码" align="center" prop="productCode"  :show-overflow-tooltip="true"/>
      
      <el-table-column label="产品名" align="center" prop="productName"  :show-overflow-tooltip="true"/>
      <!-- <el-table-column
        label="产品规格型号"
        align="center"
        prop="productModel"
      />
      <el-table-column label="产品单位" align="center" prop="productUnit" /> -->
      <el-table-column
        label="入库状态"
        align="center"
        prop="inStatus"
        :formatter="inStatusFormat"
         :show-overflow-tooltip="true"
      />
      <el-table-column label="打包单号" align="center" prop="packingNum"  :show-overflow-tooltip="true"/>
      <el-table-column label="数量" align="center" prop="quantity"  :show-overflow-tooltip="true"/>
      <el-table-column label="打包人" align="center" prop="packer"  :show-overflow-tooltip="true"/>
      <el-table-column
        label="打包时间"
        align="center"
        prop="packingTime"
        
         :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.packingTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报工单号" align="center" prop="reportNum"  :show-overflow-tooltip="true"/>
      <el-table-column label="创建人" align="center" prop="createUser"  :show-overflow-tooltip="true"/>
      <el-table-column label="修改人" align="center" prop="updateUser"  :show-overflow-tooltip="true"/>
      <el-table-column label="备注" align="center" prop="remark"  :show-overflow-tooltip="true"/>

      <el-table-column
        label="状态类型"
        align="center"
        prop="stateType"
        :formatter="stateTypeFormat"
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="打包状态"
        align="center"
        prop="packingStatus"
        :formatter="packingStatusFormat"
         :show-overflow-tooltip="true"
      />
      <el-table-column
        label="审核状态"
        align="center"
        prop="auditStatus"
        :formatter="auditStatusFormat"
         :show-overflow-tooltip="true"
      />
      <el-table-column label="来源" align="center" prop="source"  :show-overflow-tooltip="true"/>
      <el-table-column label="仓库" align="center" prop="lssuingWarehouse"  :show-overflow-tooltip="true"/>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
         :show-overflow-tooltip="true"
      >
        <!-- <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['prodmanage:packing:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['prodmanage:packing:remove']"
          >删除</el-button>
        </template> -->
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改生产打包对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="工单号" prop="orderNum">
          <el-input v-model="form.orderNum" placeholder="请输入工单号" disabled />
        </el-form-item>
        <!-- <el-form-item label="产品id" prop="productId">
          <el-input v-model="form.productId" placeholder="请输入产品id" />
        </el-form-item> -->
          <el-form-item label="产品代码" prop="productCode">
          <el-input v-model="form.productCode" placeholder="请输入产品名" disabled />
        </el-form-item>
        <el-form-item label="产品名" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名" disabled />
        </el-form-item>
        <!-- <el-form-item label="产品规格型号" prop="productModel">
          <el-input
            v-model="form.productModel"
            placeholder="请输入产品规格型号"
          />
        </el-form-item>
        <el-form-item label="产品单位" prop="productUnit">
          <el-input v-model="form.productUnit" placeholder="请输入产品单位" />
        </el-form-item> -->
        <el-form-item label="入库状态" prop="inStatus">
          <el-select
            v-model="form.inStatus"
            placeholder="请选择入库状态"
            disabled
          >
            <el-option
              v-for="dict in inStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="打包单号" prop="packingNum">
          <el-input v-model="form.packingNum" placeholder="请输入打包单号"  disabled/>
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input v-model="form.quantity" placeholder="请输入数量"  disabled/>
        </el-form-item>
        <!-- <el-form-item label="打包人" prop="packer">
          <el-input v-model="form.packer" placeholder="请输入打包人" />
        </el-form-item> -->
        <!-- <el-form-item label="打包时间" prop="packingTime">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.packingTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择打包时间"
          >
          </el-date-picker>
        </el-form-item> -->
        <el-form-item label="报工单号" prop="reportNum">
          <el-input v-model="form.reportNum" placeholder="请输入报工单号"  disabled/>
        </el-form-item>
        <!-- <el-form-item label="创建人" prop="createUser">
          <el-input v-model="form.createUser" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="修改人" prop="updateUser">
          <el-input v-model="form.updateUser" placeholder="请输入修改人" />
        </el-form-item> -->
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注"  disabled/>
        </el-form-item>
        <!-- <el-form-item label="是否删除  0否  1是" prop="isDel">
          <el-input
            v-model="form.isDel"
            placeholder="请输入是否删除  0否  1是"
          />
        </el-form-item> -->
        <el-form-item
          label="状态类型"
          prop="stateType"
        >
          <el-select
            v-model="form.stateType"
            placeholder="请选择状态类型"
            disabled
          >
            <el-option
              v-for="dict in stateTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="打包状态" prop="packingStatus">
          <el-select v-model="form.packingStatus" placeholder="请选择打包状态" disabled>
            <el-option
              v-for="dict in packingStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态" prop="auditStatus">
          <el-select v-model="form.auditStatus" placeholder="请选择审核状态" disabled>
            <el-option
              v-for="dict in auditStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="来源" prop="source">
          <el-input v-model="form.source" placeholder="请输入来源" />
        </el-form-item> -->
       

        <el-form-item label="仓库" prop="lssuingWarehouse">
          <el-select v-model="form.lssuingWarehouse" placeholder="请选择仓库">
             <el-option
              v-for="dict in lssuingWarehouseOptions"
              :key="dict.name"
              :label="dict.name"
              :value="dict.name"
            ></el-option>
          </el-select>
        </el-form-item>



        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改生产打包对话框 -->
    <el-dialog :title="title" :visible.sync="open1" width="500px" append-to-body>
      <el-form ref="form1" :model="form1" :rules="rules1" label-width="80px">
        <el-form-item label="工单号" prop="orderNum">
          <el-input v-model="form1.orderNum" placeholder="请输入工单号"  />
        </el-form-item>
        <!-- <el-form-item label="产品id" prop="productId">
          <el-input v-model="form.productId" placeholder="请输入产品id" />
        </el-form-item> -->
          <el-form-item label="产品代码" prop="productCode">
          <el-input v-model="form1.productCode" placeholder="请输入产品名"  />
        </el-form-item>
        <el-form-item label="产品名" prop="productName">
          <el-input v-model="form1.productName" placeholder="请输入产品名"  />
        </el-form-item>
        <!-- <el-form-item label="产品规格型号" prop="productModel">
          <el-input
            v-model="form.productModel"
            placeholder="请输入产品规格型号"
          />
        </el-form-item>
        <el-form-item label="产品单位" prop="productUnit">
          <el-input v-model="form.productUnit" placeholder="请输入产品单位" />
        </el-form-item> -->
        <el-form-item label="入库状态" prop="inStatus">
          <el-select
            v-model="form1.inStatus"
            placeholder="请选择入库状态"
            
          >
            <el-option
              v-for="dict in inStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="打包单号" prop="packingNum">
          <el-input v-model="form1.packingNum" placeholder="请输入打包单号"  />
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input v-model="form1.quantity" placeholder="请输入数量"  />
        </el-form-item>
        <!-- <el-form-item label="打包人" prop="packer">
          <el-input v-model="form.packer" placeholder="请输入打包人" />
        </el-form-item> -->
        <!-- <el-form-item label="打包时间" prop="packingTime">
          <el-date-picker
            clearable
            size="small"
            style="width: 200px"
            v-model="form.packingTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择打包时间"
          >
          </el-date-picker>
        </el-form-item> -->
        <el-form-item label="报工单号" prop="reportNum">
          <el-input v-model="form1.reportNum" placeholder="请输入报工单号"  />
        </el-form-item>
        <!-- <el-form-item label="创建人" prop="createUser">
          <el-input v-model="form.createUser" placeholder="请输入创建人" />
        </el-form-item>
        <el-form-item label="修改人" prop="updateUser">
          <el-input v-model="form.updateUser" placeholder="请输入修改人" />
        </el-form-item> -->
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form1.remark" placeholder="请输入备注"  />
        </el-form-item>
        <!-- <el-form-item label="是否删除  0否  1是" prop="isDel">
          <el-input
            v-model="form.isDel"
            placeholder="请输入是否删除  0否  1是"
          />
        </el-form-item> -->
        <el-form-item
          label="状态类型"
          prop="stateType"
        >
          <el-select
            v-model="form1.stateType"
            placeholder="请选择状态类型"
            
          >
            <el-option
              v-for="dict in stateTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="打包状态" prop="packingStatus">
          <el-select v-model="form1.packingStatus" placeholder="请选择打包状态" >
            <el-option
              v-for="dict in packingStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态" prop="auditStatus">
          <el-select v-model="form1.auditStatus" placeholder="请选择审核状态" >
            <el-option
              v-for="dict in auditStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="parseInt(dict.dictValue)"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="来源" prop="source">
          <el-input v-model="form.source" placeholder="请输入来源" />
        </el-form-item> -->
       

        <el-form-item label="仓库" prop="lssuingWarehouse">
          <el-select v-model="form1.lssuingWarehouse" placeholder="请选择仓库">
             <el-option
              v-for="dict in lssuingWarehouseOptions"
              :key="dict.name"
              :label="dict.name"
              :value="dict.name"
            ></el-option>
          </el-select>
        </el-form-item>



        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPacking,
  getPacking,
  delPacking,
  addPacking,
  updatePacking,
  updatePackingg,
  exportPacking,
  listWarehouse
} from "@/api/prodmanage/packing";

export default {
  name: "Packing",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产打包表格数据
      packingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1:false,
      // 入库状态(0=未入库，1=已入库)字典
      inStatusOptions: [],
      // 状态类型(0=良品 1=不良品 2=待检品)字典
      stateTypeOptions: [],
      // 打包状态字典
      packingStatusOptions: [],
      // 审核状态字典
      auditStatusOptions: [],
      //仓库名
      lssuingWarehouseOptions:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNum: undefined,
        productId: undefined,
        productName: undefined,
        productModel: undefined,
        productUnit: undefined,
        inStatus: undefined,
        packingNum: undefined,
        quantity: undefined,
        packer: undefined,
        packingTime: undefined,
        reportNum: undefined,
        createUser: undefined,
        updateUser: undefined,
        isDel: undefined,
        stateType: undefined,
        packingStatus: undefined,
        auditStatus: undefined,
        source: undefined,
        lssuingWarehouse: undefined,
        productCode:undefined,
        prodProperties:undefined
      },
      // 表单参数
      form: {},
      form1:{},
      // 表单校验
      rules: {},
            rules1: {},

    };
  },
  created() {
    this.getList();
    this.getDicts("prodmanage_packing_in_status").then((response) => {
      this.inStatusOptions = response.data;
    });
    this.getDicts("prodmanage_packaging_state_type").then((response) => {
      this.stateTypeOptions = response.data;
    });
    this.getDicts("prodmanage_packing_packing_status").then((response) => {
      this.packingStatusOptions = response.data;
    });
    this.getDicts("prodmanage_audit_status").then((response) => {
      this.auditStatusOptions = response.data;
    });
  },
  methods: {
    /** 查询生产打包列表 */
    getList() {
      this.loading = true;
      listPacking(this.queryParams).then((response) => {
        this.packingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

        //查询仓库
    getlistWarehouse() {
      listWarehouse().then((response) => {
        this.lssuingWarehouseOptions = response.rows;
        console.log(this.lssuingWarehouseOptions)
      });
    },

    
    // 入库状态(0=未入库，1=已入库)字典翻译
    inStatusFormat(row, column) {
      return this.selectDictLabel(this.inStatusOptions, row.inStatus);
    },
    // 状态类型(0=良品 1=不良品 2=待检品)字典翻译
    stateTypeFormat(row, column) {
      return this.selectDictLabel(this.stateTypeOptions, row.stateType);
    },
    // 打包状态字典翻译
    packingStatusFormat(row, column) {
      return this.selectDictLabel(this.packingStatusOptions, row.packingStatus);
    },
    // 审核状态字典翻译
    auditStatusFormat(row, column) {
      return this.selectDictLabel(this.auditStatusOptions, row.auditStatus);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.open1 = false;
      this.reset();
      this.reset1();
    },
    // 表单重置
    reset() {
      this.form = {
        packingId: undefined,
        orderNum: undefined,
        productId: undefined,
        productName: undefined,
        productModel: undefined,
        productUnit: undefined,
        inStatus: undefined,
        packingNum: undefined,
        quantity: undefined,
        packer: undefined,
        packingTime: undefined,
        reportNum: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        remark: undefined,
        isDel: undefined,
        stateType: undefined,
        packingStatus: undefined,
        auditStatus: undefined,
        source: undefined,
        lssuingWarehouse: undefined,
        productCode:undefined,
        prodProperties:undefined
      };
      this.resetForm("form");
    },
    reset1() {
      this.form1 = {
        packingId: undefined,
        orderNum: undefined,
        productId: undefined,
        productName: undefined,
        productModel: undefined,
        productUnit: undefined,
        inStatus: undefined,
        packingNum: undefined,
        quantity: undefined,
        packer: undefined,
        packingTime: undefined,
        reportNum: undefined,
        createTime: undefined,
        createUser: undefined,
        updateTime: undefined,
        updateUser: undefined,
        remark: undefined,
        isDel: undefined,
        stateType: undefined,
        packingStatus: undefined,
        auditStatus: undefined,
        source: undefined,
        lssuingWarehouse: undefined,
        productCode:undefined,
        prodProperties:undefined
      };
      this.resetForm("form1");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.packingId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset1();
      this.open1 = true;
      this.title = "添加生产打包";
    },
    /** 修改按钮操作 */
    handleUpdatee(row) {
      this.reset();
      const packingId = row.packingId || this.ids
      getPacking(packingId).then(response => {
        this.form1 = response.data;
        this.open1 = true;
        this.title = "修改生产打包";
      });
    },
    /** 入库钮操作 */
    handleUpdate(row) {
      this.reset();
      this.getlistWarehouse();
      const packingId = row.packingId || this.ids;
      getPacking(packingId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "入库";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.packingId != null) {
            updatePacking(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPacking(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 提交按钮 */
    submitFormm() {
      this.$refs["form1"].validate((valid) => {
        if (valid) {
          if (this.form1.packingId != null) {
            updatePackingg(this.form1).then((response) => {
              this.msgSuccess("修改成功");
              this.open1 = false;
              this.getList();
            });
          } else {
            addPacking(this.form1).then((response) => {
              this.msgSuccess("新增成功");
              this.open1 = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const packingIds = row.packingId || this.ids;
      this.$confirm(
        '是否确认删除生产打包编号为"' + packingIds + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delPacking(packingIds);
        })
        .then(response => {
          this.getList();
          this.msgSuccess(response.msg);
        });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有生产打包数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportPacking(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>